<%--
  Created by IntelliJ IDEA.
  User: gaosubo
  Date: 2020/9/12
  Time: 18:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>申报任务</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/lib/layui/layui/css/layui.css"/>
    <script type="text/javascript" src="/js/news/jquery-1.9.1.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery/jquery.cookie.js"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/js/common/fileupload.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>
</head>
<style>
    .btn {
        text-align: right;
    }
    .layui-form-item {
        margin-bottom: 5px;
    }
    .layui-input-inline{
        width: 300px !important;
    }
    .layui-icon-ok{
        margin-top: 6px;
    }

    .item{
        line-height: 40px;
        margin-top: 8px;
        margin: 8px;
        margin-left: 20px;
    }
    .openFile input[type=file]{
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 18px;
        z-index: 99;
        opacity: 0;
    }
</style>
<body>
<div>
    <div class="item">
        <span style="font-size: 22px;display: inline-block;vertical-align: middle;">申报任务</span>
    </div>
    <hr class="layui-bg-blue">
    <div>
        <div class="btn">
            <div style="margin-left: 10px;float: left" class="layui-form">
                <input type="radio" checked name="status"  lay-filter="status" value="" title="未审核">
                <input type="radio" name="status" value="1"  lay-filter="status" title="通过">
                <input type="radio" name="status" value="2"  lay-filter="status" title="退回">
                <input type="radio" name="status" value="2"  lay-filter="status" title="不通过">
            </div>
            <div>
                <a href="/Recognize/getRecogize?ctreateType=4&trType=14&isExport=true" type="button" class="layui-btn immp layui-btn-sm " style="margin-right: 15px" >
                    <i class="layui-icon">&#xe601;</i>
                    导出
                </a>
            </div>
        </div>
    </div>
    <div>
        <table class="layui-hide" id="test" lay-filter="test"></table>
    </div>
</div>


</body>
</html>
<script type="text/html" id="barDemo">
    <div class="layui-btn-container">
        {{#  if(d.rpmTopicList.length<2 && d.state==1){ }}
        <a class="layui-btn layui-btn-xs" lay-event="addCheckData">申报</a>
        {{#  } }}
        <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="look">查看</a>
    </div>
</script>
<script>
    var ue;   //编辑器的返回值
    var table,form,laydate,upload,laydate;
    //关闭弹框刷新页面
    function closes(){
        layer.closeAll();
        table.reload('test');
    }
    layui.use(['table', 'layer', 'form','laydate','upload'], function () {
            table = layui.table
            , layer = layui.layer
            , form = layui.form
            , upload = layui.upload
            , laydate = layui.laydate
        $(document).ready(function(){
            form.render();
        });
        var tableInt = table.render({
            elem: '#test'
            , url: '/Recognize/getRecogize'
            // , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            ,parseData: function(res){ //res 即为原始返回的数据
                return {
                    "code":0, //解析接口状态
                    "data": res.obj, //解析数据列表，
                    "count": res.totleNum, //解析数据长度
                };
            }
            , defaultToolbar: ['']
            ,where:{
                ctreateType:4,
                trType:14,
            }
            , cols: [[
                {type: 'checkbox'},
                {field: 'planName', title: '任务名称', align: 'center'}
                , {field: 'state', title: '申报状态',templet: function(d){
                        if(d.state=='1'){
                            return '申报中'
                        }else if(d.state=='2'){
                            return '申报结束'
                        }
                    }}
                , {field: 'beginDate', title: '开始日期', align: 'center'}
                , {field: 'endDate', title: '结束日期', align: 'center'}
                , {field: 'type', title: '操作', toolbar: '#barDemo'}
            ]],
            page:true,
        });

        //监听顶部单选按钮
        form.on('radio(status)', function(data){
            var value = data.value;

            table.reload('test', {
                where:{
                    state:value
                }
            });
        });

        //监听行工具事件
        table.on('tool(test)', function(obj){
            var layEvent = obj.event;
            var tr = obj.tr;
            var data = obj.data;
            if(layEvent === 'addCheckData'){
                layer.open({
                    type: 2,
                    title:'申报',
                    btn: ['保存', '保存并提交'],
                    area: ['70%', '85%'],
                    content: '/Results/declaration?planId='+data.planId+'&des='+escape(data.planName),
                    yes:function (index, layero) {
                        var myIframe = window[layero.find('iframe')[0]['name']];
                        var fnc = myIframe.submitEdit();
                    },
                    btn2:function (index, layero) {
                        var saveIframe = window[layero.find('iframe')[0]['name']];
                        var fnc = saveIframe.submitsave();
                    }
                })
            }else if(layEvent === 'look'){
                console.log(data)
                layer.open({
                    type: 1,
                    title:'查看',
                    btn: ['返回'],
                    area: ['40%', '70%'],
                    content: '<div id="cont" style="margin: 10px">\n' +
                        '        <form class="layui-form" action="" id="ajaxforms" lay-filter="ajaxforms">\n' +
                        '            <div class="layui-form-item" style="margin-top: 15px">\n' +
                        '                <div class="layui-inline">\n' +
                        '                   <label class="layui-form-label">申报计划:</label>\n' +
                        '                    <div class="layui-input-inline">\n' +
                        '                        <input type="text" name="planName" lay-verify="required|phone" autocomplete="off"\n' +
                        '                               class="layui-input required">\n' +
                        '                    </div>\n' +
                        '                </div>\n' +
                        '            </div>\n' +
                        '            <div class="layui-form-item">\n' +
                        '                <div class="layui-inline">\n' +
                        '                    <div class="layui-form-item layui-form-text">\n' +
                        '                        <label class="layui-form-label">计划描述</label>\n' +
                        '                        <div class="layui-input-inline">\n' +
                        '                            <textarea placeholder="请输入内容" class="layui-textarea des required"  name="des"></textarea>\n' +
                        '                        </div>\n' +
                        '                    </div>\n' +
                        '                </div>\n' +
                        '            </div>\n' +
                        '            <div class="layui-form-item">\n' +
                        '                <div class="layui-inline">\n' +
                        '                    <label class="layui-form-label">开始日期</label>\n' +
                        '                    <div class="layui-input-inline">\n' +
                        '                        <input type="text" name="beginDate" id="date" lay-verify="date"\n' +
                        '                               autocomplete="off" class="layui-input required">\n' +
                        '                    </div>\n' +
                        '                </div>\n' +
                        '            </div>\n' +
                        '            <div class="layui-form-item">\n' +
                        '                <div class="layui-inline">\n' +
                        '                    <label class="layui-form-label">结束日期</label>\n' +
                        '                    <div class="layui-input-inline">\n' +
                        '                        <input type="text" name="endDate" id="date1" lay-verify="date"\n' +
                        '                               autocomplete="off" class="layui-input required">\n' +
                        '                    </div>\n' +
                        '                </div>\n' +
                        '            </div>\n' +
                        '            <div class="layui-form-item">\n' +
                        '                <label class="layui-form-label">申报状态</label>\n' +
                        '                <div class="layui-input-inline">\n' +
                        '                    <input type="radio" name="state" value="1" title="申报中" checked="">\n' +
                        '                    <input type="radio" name="state" value="2" title="申报结束">\n' +
                        '                </div>\n' +
                        '            </div>\n' +
                        ' <div class="layui-form-item"  style="margin-top:15px">\n' +
                        '    <label class="layui-form-label" style="width: 100px;margin-left:-20px">上传附件</label>\n' +
                        '    <div class="layui-input-inline">\n' +
                        '<div id="fujians"></div>' +
                        ' <div id="fileAll">\n' +
                        '</div>\n' +
                        '<a href="javascript:;" class="openFile" style="float: left;margin-top:8px;position:relative">\n' +
                        '<img src="../img/mg11.png" alt="">\n' +
                        '<span>添加附件</span>\n' +
                        '<input type="file" multiple id="fileupload" data-url="/upload?module=fixAssets" name="file">\n' +
                        '</a>\n' +
                        '</div>\n' +
                        '</div>' +
                        '        </form>\n' +
                        '    </div>',
                    success:function (res) {
                        $('#ajaxforms input,textarea').attr('disabled','disabled')
                        $('.deImgs').hide()
                        $('.openFile').hide()
                        form.render();
                        fileuploadFn('#fileupload', $('#fileAll'));
                        var str = ''
                        if(data.attachmentList == undefined){
                            str='';
                        }else if(data.attachmentList.length>0){
                            for(var i=0;i<data.attachmentList.length;i++){
                                str+='<div class="dech" deUrl="' +data.attachmentList[i].attUrl + '"><a href="/download?' + data.attachmentList[i].attUrl + '" NAME="' + data.attachmentList[i].attachName +'*"><img style="margin-right:10px;" src="/img/attachment_icon.png"/>' + data.attachmentList[i].attachName + '</a><img class="deImgs" style="margin-left:5px;cursor: pointer;" src="/img/file/icon_deletecha_03.png"/><input type="hidden" class="inHidden" value="' + data.attachmentList[i].aid + '@' + data.attachmentList[i].ym + '_' + data.attachmentList[i].attachId +',"></div>'
                            }
                        }
                        $('#fujians').html(str)
                        form.val('ajaxforms', data);

                    }
                })
            }
        });
    })



</script>
